package com.usian.controller;

import com.usian.feign.UserFeign;
import com.usian.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/consumer/user")
public class UserController {

    @Autowired
    private UserFeign userFeign;


    @RequestMapping("/findById")
    @ResponseBody
    public User findById(Integer userId){
        return userFeign.findById(userId);
    }

    @RequestMapping("/findAll")
    public String findAll(Model model){
        List<User> all = userFeign.findAll();
        model.addAttribute("list",all);
        return "list";
    }

}
